package com.spring.demo.publicutil.thread;

/**
 * @author yjc
 * @date 2023/9/15
 */
public class Text1 {
    static volatile int flag = 1;
    public static void main(String[] args) {
        System.out.println(text());

        StringBuffer sb = new StringBuffer();

        System.out.println(1);
        for (int i = 1 ; i < 100 ;i++){

        }
        /*Thread t1 = new Thread() {
            @Override
            public void run() {
                while (flag<100 ) {
                    if( flag % 2 == 1){
                        System.out.println("这是线程1="+flag);
                        flag ++ ;
                    }

                }
            }
        };
        Thread t2 = new Thread() {
            @Override
            public void run() {
                while (flag<100 ) {
                    if(flag % 2 == 0 ){
                        System.out.println("2");
                        flag ++;
                    }

                }
            }
        };
        t1.start();
        t2.start();*/
    }

    public static int text(){
        int a = 2;
        try{
            a= a/0;
            System.out.println("1111");
            return a;
        }catch (Exception e){
            a = 3;
            System.out.println("2222");
            return a;

        }finally {
            a=4;
            return a;
        }

    }
}